home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 8
/
Amoszine 8 (Disk 2 of 3).adf
/
Powerbobs.lha
/
powerbobsv1.0
/
examples
/
power_bubbles.asc
< prev
next >
Wrap
Text File
|
1995-07-04
|
9KB
|
347 lines
'compile to see the difference ok
'by andy dobinson. graphics used with permission by brian bell
'
'***************************************************************************
'Adapted by PowerSoft.
'***************************************************************************
'
'To see the real speed answer N to wait for Vbl !
'
Load "df0:examples/demo.abk" : Rem demo.abk is supplied, change path !
'
Dim XPOWER25(64),YPOWER25(64),IPOWER25(64),SPDPOWER25(64)
Dim XPOWER50(64),YPOWER50(64),IPOWER50(64),SPDPOWER50(64)
Dim XAMOS25(64),YAMOS25(64),IAMOS25(64),SPDAMOS25(64)
Dim XAMOS50(64),YAMOS50(64),IAMOS50(64),SPDAMOS50(64)
Dim XDRAW25(64),YDRAW25(64),IMDRAW25(64),SPDDRAW25(64)
Global XPOWER25(),YPOWER25(),IPOWER25(),SPDPOWER25()
Global XPOWER50(),YPOWER50(),IPOWER50(),SPDPOWER50()
Global XAMOS25(),YAMOS25(),IAMOS25(),SPDAMOS25()
Global XAMOS50(),YAMOS50(),IAMOS50(),SPDAMOS50()
Global XDRAW25(),YDRAW25(),IMDRAW25(),SPDDRAW25()
Global POWER25#,POWER50#,AMOS25#,AMOS50#,POWER_DRAW25#
Global _RANDOM,VBL,AMOUNT_BOBS
Global AMOUNT_HALF,AM_HALF1
Do
Screen Open 0,640,200,4,Hires
Input "Amount of Bobs, even and max 64 : ";AMOUNT_BOBS
If AMOUNT_BOBS=0 Then Erase 1 : Erase 10 : End
AMOUNT_HALF=AMOUNT_BOBS/2
AM_HALF1=AMOUNT_HALF+1
Input "Random bubble size (Y/N) : ";_RAND$
Input "Wait for Vbl (Y/N) : ";VBL$
_RAND$=Upper$(_RAND$)
If _RAND$="Y"
_RANDOM=True
Else
_RANDOM=False
End If
VBL$=Upper$(VBL$)
If VBL$="Y"
VBL=True
Else
VBL=False
End If
Unpack 10 To 0
Screen Open 1,320,50,4,L
Screen Display 1,,241,,
Curs Off : Flash Off
Cls 0
Screen 0
Make Mask
Hide On
Double Buffer : Autoback 0 : Bob Update Off : Sprite Update Off
For T=1 To AMOUNT_BOBS
YPOWER25(T)=160
YPOWER50(T)=160
YAMOS25(T)=160
YAMOS50(T)=160
YDRAW25(T)=150
X=Rnd(320)
XPOWER25(T)=X
XPOWER50(T)=X
XAMOS25(T)=X
XAMOS50(T)=X
XDRAW25(T)=X
SPEED=Rnd(5)+1
SPDPOWER25(T)=SPEED
SPDPOWER50(T)=SPEED
SPDAMOS25(T)=SPEED
SPDAMOS50(T)=SPEED
SPDDRAW25(T)=SPEED
If _RANDOM
IMAGE=Rnd(2)+1
Else
IMAGE=1
End If
IPOWER25(T)=IMAGE
IPOWER50(T)=IMAGE
IAMOS25(T)=IMAGE
IAMOS50(T)=IMAGE
IMDRAW25(T)=IMAGE
Next T
Reserve Pbobs AMOUNT_BOBS
Pbob Dbuf True
For I=1 To AMOUNT_BOBS : Pbob Height I,23 : Next
Multi No
POWER25DRAW
POWER25UPDATE
POWER50UPDATE
AMOS25UPDATE
AMOS50UPDATE
Multi Yes
Autoback 2
Bob Off
Bob Update
Cls 0
Print "Pbob draw time 25 fps : ";POWER_DRAW25#
Print "Pbob update time 25 Fps : ";POWER25#
Print "Pbob update time 50 Fps : ";POWER50#
Print "Bob update time 25 Fps : ";AMOS25#
Print "Bob update time 50 Fps : ";AMOS50#
Wait Key
Loop
Procedure POWER25UPDATE
Screen 1
Locate 0,0
Print "Update Pbob bubbles 25 fps."
Print "Press any key."
Multi Yes
Wait Key
Multi No
Screen 0
XSPR=0
TIME=Timer
For I=1 To 300
A=1-A
If A=0
For T=AM_HALF1 To AMOUNT_BOBS
Add YPOWER25(T),-SPDPOWER25(T)
If YPOWER25(T)<1
YPOWER25(T)=200
XPOWER25(T)=Rnd(320)
SPDPOWER25(T)=Rnd(5)+1
If _RANDOM
Add IPOWER25(T),1,1 To 3
End If
End If
Next T
Pbob Varptr(XPOWER25(AM_HALF1)),Varptr(YPOWER25(AM_HALF1)),Varptr(IPOWER25(AM_HALF1)),AM_HALF1 To AMOUNT_BOBS
Else
For T=1 To AMOUNT_HALF
Add YPOWER25(T),-SPDPOWER25(T)
If YPOWER25(T)<1
YPOWER25(T)=200
XPOWER25(T)=Rnd(320)
SPDPOWER25(T)=Rnd(5)+1
If _RANDOM
Add IPOWER25(T),1,1 To 3
End If
End If
Next T
Pbob Varptr(XPOWER25(1)),Varptr(YPOWER25(1)),Varptr(IPOWER25(1)),1 To AMOUNT_HALF
Pbob Update
Screen Swap
End If
Add XSPR,3,128 To 410
Sprite 0,XSPR,100,2
Sprite 2,XSPR,150,2
Sprite 4,XSPR,180,2
If VBL
Wait Vbl
End If
Sprite Update
Next
POWER25#=Timer-TIME
Pbob Off
Pbob Update
Screen Swap
Pbob Update
Screen Swap
End Proc
Procedure POWER50UPDATE
Screen 1
Locate 0,0
Print "Update Pbob bubbles 50 fps."
Print "Press any key."
Multi Yes
Wait Key
Multi No
Screen 0
XSPR=0
TIME=Timer
For I=1 To 300
For T=1 To AMOUNT_BOBS
Add YPOWER50(T),-SPDPOWER50(T)
If YPOWER50(T)<1
YPOWER50(T)=200
XPOWER50(T)=Rnd(240)
SPDPOWER50(T)=Rnd(5)+1
If _RANDOM
Add IPOWER50(T),1,1 To 3
End If
End If
Next T
Pbob Varptr(XPOWER50(1)),Varptr(YPOWER50(1)),Varptr(IPOWER50(1)),1 To AMOUNT_BOBS
Pbob Update
Screen Swap
Add XSPR,3,128 To 410
Sprite 0,XSPR,100,2
Sprite 2,XSPR,150,2
Sprite 4,XSPR,180,2
If VBL
Wait Vbl
End If
Sprite Update
Next
POWER50#=Timer-TIME
Pbob Off
Pbob Update
Screen Swap
Pbob Update
Screen Swap
End Proc
Procedure AMOS25UPDATE
Screen 1
Locate 0,0
Print "Update Bob bubbles 25 fps."
Print "Press any key."
Multi Yes
Wait Key
Multi No
Screen 0
XSPR=0
A=0
TIME=Timer
For I=1 To 300
A=1-A
If A=0
For T=AM_HALF1 To AMOUNT_BOBS
Add YAMOS25(T),-SPDAMOS25(T)
If YAMOS25(T)<1
YAMOS25(T)=200
XAMOS25(T)=Rnd(320)
SPDAMOS25(T)=Rnd(5)+1
If _RANDOM
Add IAMOS25(T),1,1 To 3
End If
End If
Bob T,XAMOS25(T),YAMOS25(T),IAMOS25(T)
Next T
Else
For T=1 To AMOUNT_HALF
Add YAMOS25(T),-SPDAMOS25(T)
If YAMOS25(T)<1
YAMOS25(T)=200
XAMOS25(T)=Rnd(320)
SPDAMOS25(T)=Rnd(5)+1
If _RANDOM
Add IAMOS25(T),1,1 To 3
End If
End If
Bob T,XAMOS25(T),YAMOS25(T),IAMOS25(T)
Next T
Bob Update
End If
Add XSPR,3,128 To 410
Sprite 0,XSPR,100,2
Sprite 2,XSPR,150,2
Sprite 4,XSPR,180,2
If VBL
Wait Vbl
End If
Sprite Update
Next
AMOS25#=Timer-TIME
End Proc
Procedure AMOS50UPDATE
Screen 1
Locate 0,0
Print "Update Bob bubbles 50 fps."
Print "Press any key."
Multi Yes
Wait Key
Multi No
Screen 0
XSPR=0
TIME=Timer
For I=1 To 300
For T=1 To AMOUNT_BOBS
Add YAMOS50(T),-SPDAMOS50(T)
If YAMOS50(T)<1
YAMOS50(T)=200
XAMOS50(T)=Rnd(320)
SPDAMOS50(T)=Rnd(5)+1
If _RANDOM
Add IAMOS50(T),1,1 To 3
End If
End If
Bob T,XAMOS50(T),YAMOS50(T),IAMOS50(T)
Next
Bob Update
Add XSPR,3,128 To 410
Sprite 0,XSPR,100,2
Sprite 2,XSPR,150,2
Sprite 4,XSPR,180,2
If VBL
Wait Vbl
End If
Sprite Update
Next
AMOS50#=Timer-TIME
End Proc
Procedure POWER25DRAW
Screen 1
Locate 0,0
Print "Draw Pbob bubbles 25 fps."
Print "Press any key."
Multi Yes
Wait Key
Multi No
Screen 0
XSPR=0
Pdraw 25fps True
TIME=Timer
For I=1 To 300
A=1-A
If A=1
Pbob Clear 1 To AMOUNT_BOBS
For T=AM_HALF1 To AMOUNT_BOBS
Add YDRAW25(T),-SPDDRAW25(T)
If YDRAW25(T)<0
YDRAW25(T)=200
XDRAW25(T)=Rnd(320)
SPDDRAW25(T)=Rnd(4)+1
End If
Next T
Pbob Varptr(XDRAW25(AM_HALF1)),Varptr(YDRAW25(AM_HALF1)),Varptr(IMDRAW25(AM_HALF1)),AM_HALF1 To AMOUNT_BOBS
Pbob Draw AM_HALF1 To AMOUNT_BOBS
Else
For T=1 To AMOUNT_HALF
Add YDRAW25(T),-SPDDRAW25(T)
If YDRAW25(T)<0
YDRAW25(T)=200
XDRAW25(T)=Rnd(320)
SPDDRAW25(T)=Rnd(4)+1
End If
Next T
Pbob Varptr(XDRAW25(1)),Varptr(YDRAW25(1)),Varptr(IMDRAW25(1)),1 To AMOUNT_HALF
Pbob Draw 1 To AMOUNT_HALF
Screen Swap
End If
Add XSPR,3,128 To 410
Sprite 0,XSPR,100,2
Sprite 2,XSPR,150,2
Sprite 4,XSPR,180,2
If VBL
Wait Vbl
End If
Sprite Update
Next
POWER_DRAW25#=Timer-TIME
Pbob Clear 1 To AMOUNT_BOBS
Screen Swap
Pswap Clear
Pbob Clear 1 To AMOUNT_BOBS
End Proc